<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
	<link rel="stylesheet" href="/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/css/style.css">
    <link rel="icon" href="/image/code.png">
</head>
<body>
<div class="login-main">
    <header class="layui-elip">后台注册</header>
    <form class="layui-form" id="formId">
        <div class="layui-input-inline">
            <input type="text" name="name"  placeholder="账号" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="pwd" style="height:40px;" style="" placeholder="密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="text" name="code" style="height:40px;" style="" placeholder="注册码" autocomplete="off" class="layui-input">
        </div>
         <div class="layui-input-inline login-btn">
            <button type="button" class="layui-btn" onclick="register()">注册</button>
        </div>
        <div class="layui-input-inline login-btn">
            <button type="button" class="layui-btn layui-btn-warm" onclick="login()">返回</button>
        </div>
    </form>
</div>

<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="/frame/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form'], function () {
        var form = layui.form(), $ = layui.jquery;
    });
</script>
<script type="text/javascript">

	function login(){
		location.href="${basePath}/user/login"
	}
	function register(){
		$.ajax({
            type: "POST",
            url: "${basePath}/user/doRegister",
            data: $("#formId").serialize(),
            dataType: "json",
            success: function(data){
            	if(data.isSuccess){
            		layer.msg(data.message,{time: 500});
            		window.setTimeout(function(){
            			location.href="${basePath}/user/login"
            		},500); 
            	}else{
            		layer.msg(data.message,{time: 3000});
            	}
            },
            error: function(data){
            	layer.msg("网络错误！");
            }
        });
	}
</script>
</body>
</html>